package chen.web.message;

import chen.web.ExecuteHandler;
import chen.web.Executor;
import chen.web.config.ConfigRepository;
import chen.web.config.SiteConfig;
import chen.web.event.EventListener;
import chen.web.user.Account;
import chen.web.user.event.RegisterEvent;

public class SendRegisterMessage implements EventListener<RegisterEvent> {
	
	private MessageManager mm;
	
	public SendRegisterMessage(MessageManager mm){
		this.mm = mm;
	}

	@Override
	public void listen(RegisterEvent event) {
		// TODO Auto-generated method stub

		Account receiver = event.getRegisterAccount();
		String content = "感谢您在" + ConfigRepository.instance().get(SiteConfig.class).getSiteName() + "注册! 请牢记住自己的用户名密码, 有问题请与站长联系. ";
		
		final Message message = new Message(receiver, content);

		Executor.execute(new ExecuteHandler<Object>(){
			@Override
			public Object handle() {
				// TODO Auto-generated method stub
				mm.send(message);
				return null;
			}
		});	

	}

}
